/**
 * TCSS 360 System Q&A
 * Winter Qtr 2013
 * 
 * darksideoftheloom:
 * Michael Wamsley
 * Roger Trottier
 * Shane Kwon
 * Joshua Warner
 */
package darksideoftheloom;

import static org.junit.Assert.*;

import java.util.ArrayList;

import org.junit.Before;
import org.junit.Test;

/**
 * Test class for the Attendee class.
 * 
 * @author Michael Wamsley
 * @version 2-21-2013
 */
public class AttendeeTest {

	@Test
	//Tests the constructor and the various getters.
	public void testConstructor() {
		Attendee a1 = new Attendee("John", "360-273-7407", "55537 MyStreet", "johnny@gmail.com",
				"JohnBoy", "poptarts");
		
		assertEquals(a1.getName(), "John");
		assertEquals(a1.getPhoneNumber(), "360-273-7407");
		assertEquals(a1.getAddress(), "55537 MyStreet");
		assertEquals(a1.getEmail(), "johnny@gmail.com");
		assertEquals(a1.getUsername(), "JohnBoy");
		assertEquals(a1.getPassword(), "poptarts");
	}
	
	@Test
	//Tests the set name method.
	public void testSetName() {
		Attendee a1 = new Attendee("John", "360-273-7407", "55537 MyStreet", "johnny@gmail.com",
				"JohnBoy", "poptarts");
		
		a1.setName("Steve");
		assertEquals(a1.getName(), "Steve");
	}
	
	@Test
	//Test the set phone number class.
	public void testSetPhone() {
		Attendee a1 = new Attendee("John", "360-273-7407", "55537 MyStreet", "johnny@gmail.com",
				"JohnBoy", "poptarts");
		
		a1.setPhoneNumber("555-222-7777");
		assertEquals(a1.getPhoneNumber(), "555-222-7777");
	}
	
	@Test
	//Test the set address method.
	public void testSetAddress() {
		Attendee a1 = new Attendee("John", "360-273-7407", "55537 MyStreet", "johnny@gmail.com",
				"JohnBoy", "poptarts");
		
		a1.setAddress("1234 BounceyRoad");
		assertEquals(a1.getAddress(), "1234 BounceyRoad");
	}
	
	@Test
	//Test the set email method.
	public void testSetEmail() {
		Attendee a1 = new Attendee("John", "360-273-7407", "55537 MyStreet", "johnny@gmail.com",
				"JohnBoy", "poptarts");
		
		a1.setEmail("bigRooster@gmail.com");
		assertEquals(a1.getEmail(), "bigRooster@gmail.com");
	}
	
	@Test
	//Tests the set username method.
	public void testSetUserName() {
		Attendee a1 = new Attendee("John", "360-273-7407", "55537 MyStreet", "johnny@gmail.com",
				"JohnBoy", "poptarts");
		
		a1.setUsername("JohnMan");
		assertEquals(a1.getUsername(), "JohnMan");
	}
	
	@Test
	//Tests the set password method.
	public void testSetPassword() {
		Attendee a1 = new Attendee("John", "360-273-7407", "55537 MyStreet", "johnny@gmail.com",
				"JohnBoy", "poptarts");
		
		a1.setPassword("toastercakes");
		assertEquals(a1.getPassword(), "toastercakes");
	}
	
	@Test
	//Tests that the submissions is not null. They should
	//have been created when the Attendee was constructed.
	public void testSubmission() {
		Attendee a1 = new Attendee("John", "360-273-7407", "55537 MyStreet", "johnny@gmail.com",
				"JohnBoy", "poptarts");
		assertNotNull(a1.getSubmissions());
	}
	
	@Test
	//Tests whether you can add a submission.
	public void testAddSubmission() {
		Attendee a1 = new Attendee("John", "360-273-7407", "55537 MyStreet", "johnny@gmail.com",
				"JohnBoy", "poptarts");
		WeavingDraft d1 = new WeavingDraft(6,6,6,6);
		Submission s1 = new Submission("John", "BigRoundies","Basket", d1);
		a1.submit(s1);
		
		assertEquals(a1.getSubmissions().get(0), s1);
	}
	
	@Test
	//Tests that the remove submission is working.
	public void testRemoveSubmission() {
		Attendee a1 = new Attendee("John", "360-273-7407", "55537 MyStreet", "johnny@gmail.com",
				"JohnBoy", "poptarts");
		WeavingDraft d1 = new WeavingDraft(6,6,6,6);
		Submission s1 = new Submission("John", "BigRoundies","Basket", d1);
		a1.submit(s1);
		a1.removeSubmission(s1);
		
		for(Submission sub: a1.getSubmissions()) {
			assertEquals(sub, null);
		}
	}
	
	@Test(expected=IllegalArgumentException.class)
	//Tests whether you can add another submission of the same category.
	public void testSubmitCat() throws IllegalArgumentException {
		Attendee a1 = new Attendee("John", "360-273-7407", "55537 MyStreet", "johnny@gmail.com",
				"JohnBoy", "poptarts");
		WeavingDraft d1 = new WeavingDraft(6,6,6,6);
		Submission s1 = new Submission("John", "BigRoundies","Basket", d1);
		Submission s2 = new Submission("John", "BigRoundies", "Basket", d1);
		
		a1.submit(s1);
		a1.submit(s2);
	}
	
	@Test(expected=IllegalArgumentException.class)
	//Tests whether you can add another submission of the same category.
	public void testSubmitMore() throws IllegalArgumentException {
		Attendee a1 = new Attendee("John", "360-273-7407", "55537 MyStreet", "johnny@gmail.com",
				"JohnBoy", "poptarts");
		WeavingDraft d1 = new WeavingDraft(6,6,6,6);
		Submission s1 = new Submission("John", "BigRoundies","Basket", d1);
		Submission s2 = new Submission("John", "BigRoundies", "Flyer", d1);
		Submission s3 = new Submission("John", "BigRoundies", "Thread", d1);
		Submission s4 = new Submission("John", "BigRoundies", "Blanket", d1);
		
		a1.submit(s1);
		a1.submit(s2);
		a1.submit(s3);
		a1.submit(s4);
	}
}